#ifndef PLAYLISTWIDGET_H
#define PLAYLISTWIDGET_H

#include <QWidget>
#include <QVector>
#include "songitemwidget.h"
#include <QHash>
#include <QFile>
namespace Ui {
class PlaylistWidget;
}

class PlaylistWidget : public QWidget
{
    Q_OBJECT

public:
    explicit PlaylistWidget(QWidget *parent = nullptr);
    ~PlaylistWidget();
    bool eventFilter(QObject *watched, QEvent *event);
    void setListId(int listId);
    void addSongItem(SongItemWidget*);
    void setListImage(const QString& path);
    void setListImage(const QPixmap& pixmap);

    void on_SongManager_liked(QUrl url, bool isLike);
private:
    void on_songItem_played(int index, bool play);
    void on_songItem_downloaded();
    void updateindex();
    void storage();
    void downloadSong(qint64 id, const QString& path);
private slots:
    void on_pushButton_playAll_clicked();
    void on_pushButton_utils_clicked();

    void on_pushButton_download_clicked();

signals:
    void played(SongItem songItem, bool play);
    void playAll(const QVector<QUrl>& songs);

private:
    int _listId;
    QList<SongItemWidget*> _songItems;
//    QHash<QUrl, SongItemWidget*> _songItems;
private:
    Ui::PlaylistWidget *ui;
};

#endif // PLAYLISTWIDGET_H
